using UnityEngine;
using QFramework;

namespace survivor
{
	public partial class Player : ViewController
	{
		public float moveSpeed = 5.0f;

		public static Player ins;

        private void Awake()
        {
            ins = this;
        }

        private void OnDestroy()
        {
            ins = null;
        }

        void Start()
		{
			// Code Here
			HurBox.OnTriggerEnter2DEvent(collider2D =>
			{
				this.DestroyGameObjGracefully();
				
				UIKit.OpenPanel<UIGameOverPanel>();
			}).UnRegisterWhenGameObjectDestroyed(gameObject);
		}

        private void Update()
        {
			var horizontal = Input.GetAxis("Horizontal");
			var vertical = Input.GetAxis("Vertical");
			var direction = new Vector2 (horizontal, vertical).normalized;

			SelfRigidbody2D.velocity = direction * moveSpeed;
        }
    }
}
